--
-- Author: ping.wang
-- Date: 2019-03-11 11:10:46
--
local fileName = string.getModeName(...)
local ClassRef = class(fileName)
local UserBaseInfo = require("app.public.dao.UserBaseInfo")


function ClassRef:ctor(data)
    if data then
        self:init(data)
    end
end

function ClassRef:init(data)
    self._enmeyInfo = UserBaseInfo.new(data.enemy)
    self._win = data.win --是否胜利
    self._rankChange = data.rankChange or 0
    self._battleReportUrl = data.battleReportUrl
    self._timestamp = data.timestamp
	self._isAttacker = data.atk
end

function ClassRef:getDisplayTimeStr()
	local offlineStr = ""
	if 0 < self._timestamp then
		local curTime = app:getServerTime()
		--type=2
		--      >1天 return {day},gap
		--      <=1天 return {h,m,s},1
		local params, interval = TimeUtil.secondsToStr( ( curTime - self._timestamp ) , 2 )
		if #params == 1 then -- 超过一天？
			offlineStr = string.format( L("duelGametips31"), params[1])
		else
			local hour = params[1]
			if hour >= 1 then
				offlineStr = string.format( L("duelGametips30"), params[1])
			else
				if params[2] == 0 then
					params[2] = 1
				end

				offlineStr = string.format( L("duelGametips29"), params[2] )
			end
		end
	end
	return offlineStr
end

function ClassRef:getEnemyInfo()
	return self._enmeyInfo
end

function ClassRef:isWin()
	return self._win
end

function ClassRef:getRankChange()
	return self._rankChange
end

--我是否是进攻者
function ClassRef:isAttacker()
	return self._isAttacker
end

return ClassRef